package design.action.chain;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zxs
 * @since 2020/05/26
 */
public class ChainImpl implements Chain {

    private List<MyInterface> list = new ArrayList<>();
    private int location=0;

    public ChainImpl(){
        this.init();
    }

    private void init(){
        list.add(new MyImpl1("1"));
        list.add(new MyImpl1("2"));
        list.add(new MyImpl1("3"));
    }

    @Override
    public void doSomething(Param param) {
        if(location<list.size()){
            list.get(location++).doSomething(param,this);
        }
    }
}
